from langchain.tools import Tool, tool
import calendar
import dateutil.parser as parser
from langchain.agents import create_self_ask_with_search_agent
from langchain.agents import AgentExecutor
from langchain import hub
from MyLangChain import *

_ = load_dotenv(find_dotenv())

# search = SerpAPIWrapper()
#
# tools = [
#     Tool.from_function(
#         func=search.run,
#         name="Search",
#         description="useful for when you need to answer questions about current events"
#     ),
# ]
#
#
# # 自定义工具
# @tool("weekday")
# def weekday(date_str: str) -> str:
#     """Convert date to weekday name"""
#     d = parser.parse(date_str)
#     return calendar.day_name[d.weekday()]
#
#
# tools += [weekday]

# 下载一个现有的 Prompt 模板
prompt = hub.pull("hwchase17/react")

print(prompt.template)

# agent = create_self_ask_with_search_agent(get_llm(), tools, prompt)
# agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True, handle_parsing_errors=True)
#
# agent_executor.invoke({"input": "吴京的老婆主持过哪些综艺节目"})
